package net.arvin.view;

import net.arvin.mobilebanksystem.R;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.ListView;

public class ListDialog extends Dialog implements OnItemClickListener {

	public Context mContext;
	public ListView list;
	public ImageView isSelect;
	private MyDialogListListener mListener;

	public ListDialog(Context context, int theme, MyDialogListListener listener) {
		super(context, theme);
		this.mContext = context;
		setContentView(R.layout.dialog_list);
		DisplayMetrics metrics = context.getResources().getDisplayMetrics();
		int screenWidth = (int) (metrics.widthPixels * 0.80);
		getWindow().setLayout(screenWidth, LayoutParams.WRAP_CONTENT);
		this.mListener = listener;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		mListener.onClick(position);
	}

	public interface MyDialogListListener {
		public void onClick(int position);
	}

	public void setOnItemClickListener() {
		list.setOnItemClickListener(this);
	}

}
